package com.trmp.sys.orgMng.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.trmp.commons.service.AbstractService;
import com.trmp.sys.orgMng.dao.OrgroupPrefixRoleDao;
import com.trmp.sys.orgMng.entity.OrgGroupPrefixRoleInfo;
import com.trmp.sys.orgMng.entity.OrganInfo;
import com.trmp.sys.orgMng.model.OrgroupPrefixRoleJson;
import com.trmp.sys.orgMng.service.OrgGroupPrefixRoleService;

@Service
public class OrgGroupPrefixRoleServiceImpl extends AbstractService implements
		OrgGroupPrefixRoleService {
	@Autowired
	private OrgroupPrefixRoleDao orgroupprefixroledao;


	@Override
	public List<OrgroupPrefixRoleJson> findAllByorganId(OrganInfo organInfo) {
		List<OrgGroupPrefixRoleInfo> ls = orgroupprefixroledao
				.findAllByOrgInfo(organInfo);

		OrgroupPrefixRoleJson json = null;
		List<OrgroupPrefixRoleJson> lsorggroup = new ArrayList<OrgroupPrefixRoleJson>();
		for (OrgGroupPrefixRoleInfo org : ls) {
			json = new OrgroupPrefixRoleJson();
			json.setPrefixRoleId(org.getPrefixRoleId());
			json.setBussClasses(org.getBussClasses());
			json.setBussType(org.getBussType());
			json.setGroupPrefix(org.getGroupPrefix());
			lsorggroup.add(json);
		}
		return lsorggroup;
	}

	@Override
	public OrgGroupPrefixRoleInfo save(OrgGroupPrefixRoleInfo org) {
		OrgGroupPrefixRoleInfo orgreturn = orgroupprefixroledao.save(org);
		return orgreturn;
	}

	@Override
	public void dele(List<Long> lslong) {
		List<OrgGroupPrefixRoleInfo> ls = new ArrayList<OrgGroupPrefixRoleInfo>();
		OrgGroupPrefixRoleInfo b = null;
		for (long l : lslong) {
			b = new OrgGroupPrefixRoleInfo();
			b.setPrefixRoleId(l);
			ls.add(b);
		}

		orgroupprefixroledao.deleteInBatch(ls);
	}
}
